package com.app.shortvideo.ui.viewmodel

import android.content.Context
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.lifecycle.MutableLiveData
import com.app.shortvideo.ui.main.adapter.DramaListAdapter
import com.app.shortvideo.ui.video.VideoActivity
import com.bytedance.sdk.shortplay.api.PSSDK
import com.bytedance.sdk.shortplay.api.PSSDK.FeedListLoadResult
import com.bytedance.sdk.shortplay.api.PSSDK.FeedListResultListener
import com.bytedance.sdk.shortplay.api.ShortPlay
import java.util.Collections


class AddressViewModel : BaseViewModel() {
    val videoResult = MutableLiveData<List<ShortPlay>>()
    lateinit var adapter: DramaListAdapter
    fun queryPopularVideo() {
        PSSDK.requestPopularDrama(1, 100, object : FeedListResultListener {
            override fun onFail(errorInfo: PSSDK.ErrorInfo) {
            }

            override fun onSuccess(feedListLoadResult: FeedListLoadResult<ShortPlay>) {
                // 短剧列表
                val dataList: List<ShortPlay> = feedListLoadResult.dataList
                // 分页请求，是否还有更多数据
                val hasMore: Boolean = feedListLoadResult.hasMore
                videoResult.postValue(dataList)
            }
        })
    }
    fun showDetailPage(activity:Context,shortPlay: ShortPlay?) {
        VideoActivity.start(activity,shortPlay)
    }
}